import originAxios from '@/service'
import { IDataType } from '@/service/type'
// import { IPageSearch, IPageListResult } from './type'

// enum SearchApi {
//   PageListSearch = '/users/list'
// }
export function getUserAvatar(id: number) {
  return originAxios.get<IDataType<any>>({
    url: `/users/${id}/avatar`
  })
}
export function getPageListData(pageUrl: string, queryInfo: any) {
  return originAxios.post<IDataType<any>>({
    url: pageUrl,
    data: queryInfo
  })
}
export function deletePageData(pageUrl: string) {
  return originAxios.delete<IDataType<any>>({
    url: pageUrl
  })
}
export function createPageData(pageUrl: string, newData: any) {
  return originAxios.post<IDataType<any>>({
    url: pageUrl,
    data: newData
  })
}
export function updatePageData(pageUrl: string, editData: any) {
  return originAxios.patch<IDataType<any>>({
    url: pageUrl,
    data: editData
  })
}
export function updateFile(file: any, id: number, num: number) {
  return originAxios.post<IDataType<any>>({
    url: `/upload/picture`,
    params: {
      method: id,
      shop_id: num
    },
    data: file
  })
}
export function updateAvatar(file: any) {
  return originAxios.post<IDataType<any>>({
    url: `/upload/avatar`,
    data: file
  })
}
export function updateShopInfo(info: any, id: number) {
  return originAxios.post<IDataType<any>>({
    url: `/shops/${id}`,
    data: info
  })
}
export function updateItemFile(file: any, num: number, id: number) {
  console.log(file)

  return originAxios.post<IDataType<any>>({
    url: `/upload/picture`,
    params: {
      method: 0,
      shop_id: num,
      shop_item_id: id
    },
    data: file
  })
}
